package com.android.plc.ui.control;

import android.content.Context;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.Button;

import com.android.plc.CONST.COMMAND;
import com.android.plc.CONST;
import com.android.plc.R;

public class TVPlayControl extends NormalControl implements OnClickListener
{

	private Button mChPlusBtn;
	private Button mChMinsBtn;
	private Button mVolPlusBtn;
	private Button mVolMinsBtn;
	public static final int OFFSET_1 = 1;
	public static final int OFFSET_2 = 2;

	public TVPlayControl(Context context, ViewGroup view, int res_id)
	{
		super(context, view, res_id);
	}

	public TVPlayControl(Context context, ViewGroup view)
	{
		super(context, view, R.layout.control_tv);
	}

	@Override
	public void initView(ViewGroup view)
	{
		super.initView(view);
		
		mChPlusBtn = (Button) view.findViewById(R.id.btn_ch_plus);
		mChMinsBtn = (Button) view.findViewById(R.id.btn_ch_mins);

		mVolPlusBtn = (Button) view.findViewById(R.id.btn_vol_plus);
		mVolMinsBtn = (Button) view.findViewById(R.id.btn_vol_mins);

		mChPlusBtn.setOnClickListener(this);
		mChMinsBtn.setOnClickListener(this);

		mVolPlusBtn.setOnClickListener(this);
		mVolMinsBtn.setOnClickListener(this);
	}

	public void onClick(View v)
	{
		switch (v.getId())
		{
		case R.id.btn_ch_plus:
			sendCommand(OFFSET_1, COMMAND.ON, CONST.DEF_DATA, 0);
			break;
		case R.id.btn_ch_mins:
			sendCommand(OFFSET_1, COMMAND.OFF, 0, 0);
			break;
		case R.id.btn_vol_plus:
			sendCommand(OFFSET_2, COMMAND.ON, CONST.DEF_DATA, 0);
			break;
		case R.id.btn_vol_mins:
			sendCommand(OFFSET_2, COMMAND.OFF, 0, 0);
			break;
		default:
			super.onClick(v);
			break;
		}
	}
}
